<template>
  <div>
    <div class="yun"></div>
    <div class="loginMain" v-loading="words">
      <div class="words">
        <div ref="echartsWordcloud"></div>
      </div>
      <div class="loginBox">
        <div class="title">欢迎来到
          <div>群众呼声智慧分析平台</div>
          <img src="https://wap.mala.cn/mala/imgs/114.png" class="logo"></div>
        <div class="screen">当前分辨率{{ screenWidth }} * {{ screenHeight }}，按下键盘 F11 获得最佳体验</div>

        <el-tabs v-model="activeName" style="margin-top:20px;">
          <el-tab-pane label="账号密码登录" name="first">

            <el-form ref="loginForm" :model="loginForm" class="login-form" auto-complete="on" label-position="left">

              <el-form-item prop="username" class="el-form-item__content-focus">
                  <span class="svg-container">
                    <i class="iconfont icon-woshimaijia2"></i>
                  </span>
                <el-input
                    v-model="loginForm.username"
                    placeholder="用户名"
                    name="username"
                    type="text"
                    tabindex="1"
                    auto-complete="on"
                />
              </el-form-item>

              <el-form-item prop="password">
        <span class="svg-container">
          <i class="iconfont icon-mima"></i>
        </span>
                <el-input
                    ref="password"
                    v-model="loginForm.password"
                    placeholder="密码"
                    name="password"
                    type="password"
                    tabindex="2"
                    auto-complete="on"
                />
              </el-form-item>

              <div id="geetest"></div>
              <el-button :loading="loginloading" type="primary" size="big"
                         style="width:100%;margin-bottom:30px;height:50px;"
                         @click.native.prevent="handleLogin"
              >登录到智慧大屏
              </el-button>
              <div class="tips">
                <div style="color:#999;text-align: center">Copyright XUXIAOLONG Powered by wz.mala.cn</div>
              </div>

            </el-form>


          </el-tab-pane>
          <el-tab-pane label="手机登录" name="second"></el-tab-pane>
        </el-tabs>

      </div>
    </div>
  </div>
</template>
<script>

import drawMixin from "@/utils/drawMixin";

import {getGeet} from '@/utils/api/user'

import {getWord} from '@/utils/api/data'

import 'echarts-wordcloud'

import '@/utils/gt4'

export default {
  mixins: [drawMixin],
  name: 'Citys',
  data() {
    return {
      words: true,
      loginloading: false,
      activeName: 'first',
      screenWidth: window.screen.width,
      screenHeight: window.screen.height,
      loading: false,
      loginForm: {
        username: '',
        password: '',
        loginAuth: []
      },
    }
  },
  mounted() {

    this.$nextTick(() => {
      this.Geet();
      this.gWords()
    })
  },
  methods: {
    handleLogin() {
      this.loginloading = true
    },
    makeWords(data) {

      const el = this.$refs.echartsWordcloud
      this.chart = this.$echarts.init(el)
      let colorList = ['#819cd9', '#d3e4ff', '#d4d4ff'];
      //按照colorList指定颜色的数据进行随机
      const option = {
        tooltip: {
          show: true
        },
        series: [
          {
            // shape: 'square',
            //用来调整词之间的距离
            gridSize: 9,
            rotationRange: [0, 0],
            //用来调整字的大小范围
            sizeRange: [12, 38],
            type: 'wordCloud',
            textPadding: 0,
            left: "center",
            drawOutOfBound: false,
            shrinkToFit: true,
            layoutAnimation: false,

            // top: "center",
            textStyle: {
              color: function () {
                let index = Math.floor(Math.random() * 3);
                return colorList[index]
              },
              // fontFamily: '阿里妈妈数黑体 Bold'

            },
            data: data
          }
        ]
      }
      //设置图表的参数
      this.chart.setOption(option)
      this.words = false
    },
    gWords() {
      getWord().then(r => {
        if (r.code == 200) {
          this.makeWords(r.data)

        }
      })
    },
    Geet() {
      let _this = this
      getGeet({login: 1}).then(response => {
        let data = response.data
        initGeetest({
          gt: data.gt,
          challenge: data.challenge,
          offline: !data.success,
          new_captcha: true,
          width: '100%'
        }, function (captchaObj) {
          captchaObj.appendTo('#geetest')
          captchaObj.onSuccess(() => {
            // _this.loginAuth = captchaObj.getValidate();
            _this.$set(_this.loginForm, 'loginAuth', captchaObj.getValidate());
            // console.log(this.loginForm)
            // {
            //   "geetest_challenge": "60bc42c539750a73e345a5facd138011lf",
            //   "geetest_validate": "32c8982a7ecc364881108c04098e8eaf",
            //   "geetest_seccode": "32c8982a7ecc364881108c04098e8eaf|jordan"
            // }
          })
        })
      }).catch(err => {
      })
    },
  }
};
</script>
<style lang="scss" scoped>
$bg: #2d3a4b;
$dark_gray: #889aa4;
$light_gray: #eee;
$bg: #283443;
$light_gray: #333;
$cursor: #fff;


::v-deep {
  .el-loading-mask {
    background: transparent;
  }

  .el-form-item__content {
    line-height: 20px;

  }

  #app {
    background-image: none !important;
  }

  .loginBox {
    .login-form {
      position: relative;
      width: 520px;
      max-width: 100%;
      padding: 10px 0;
      margin: 0 auto;
      overflow: hidden;
    }

    .el-input {
      display: inline-block;
      height: 47px;
      width: 85%;

      input {
        background: transparent;
        padding-left: 15px;
        -webkit-appearance: none;
        border: 0;
        color: $light_gray;
        height: 47px;
        font-size: 14px;
      }

      input:-internal-autofill-previewed,
      input:-internal-autofill-selected {
        -webkit-text-fill-color: #000 !important;
        transition: background-color 5000s ease-in-out 0s !important;
      }
    }

    .el-form-item {
      border: 1px solid rgba(255, 255, 255, 0.1);
      border-radius: 5px;
      color: #454545;
      border: 1px solid #dde2e9;
      border-radius: 4px;
    }

    .tips {
      font-size: 14px;
      color: #fff;
      margin-bottom: 10px;

      span {
        &:first-of-type {
          margin-right: 16px;
        }
      }
    }

    .svg-container {
      padding: 6px 5px 6px 15px;
      color: $dark_gray;
      vertical-align: middle;
      width: 30px;
      display: inline-block;

      .iconfont {
        font-size: 25px;
      }
    }

    .title-container {
      position: relative;

      .title {
        font-size: 26px;
        color: $light_gray;
        margin: 0px auto 40px auto;
        text-align: center;
        font-weight: bold;
      }
    }

    .show-pwd {
      position: absolute;
      right: 10px;
      top: 7px;
      font-size: 16px;
      color: $dark_gray;
      cursor: pointer;
      user-select: none;
    }
  }
}

#geetest {
  margin-bottom: 20px;
}

@keyframes rowup {
  0% {
    -webkit-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0);
  }
  50% {
    -webkit-transform: translate3d(0, -360px, 0);
    transform: translate3d(0, -360px, 0);
  }
  100% {
    -webkit-transform: translate3d(0, -780px, 0);
    transform: translate3d(0, -780px, 0);
  }
}

@keyframes yunduo {
  0% {
    background-size: 100%;
  }
  50% {
    background-size: 200%;
  }
  100% {
    background-size: 400%;
    //transform: translateX(980px);
  }

}

.words {
  position: relative;
  left: -100px;
  min-height: 100vh;
  -webkit-animation: 40s rowup alternate infinite;
  animation: 40s rowup alternate infinite;
  position: relative;

  > div {
    position: relative;
    width: calc(1400px - 476px);
    height: 4000px;
  }
}

.loginMain {
  position: relative;
  width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  height: 100vh;
  justify-content: space-between;
}

.loginBox {
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, .05);
  box-sizing: border-box;
  height: 600px;
  padding: 48px 48px 32px;
  width: 476px;

  .screen {
    color: #999;
    text-align: center;
    font-size: 12px;
    margin: 20px 0 0;
  }

  .title {
    color: #0c0d0e;
    font-size: 28px;
    font-weight: 500;
    letter-spacing: .003em;
    line-height: 32px;
    text-align: left;
    position: relative;

    .logo {
      position: absolute;
      right: 0;
      top: 50%;
      transform: translateY(-50%);
      width: 60px;
    }

    > div {
      color: #3854af;
      font-weight: bolder;
      margin: 10px 0;
    }
  }
}
</style>
